package hbt;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import entity.*;
 
public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
             // agrego con: config.addAnnotatedClass(<nombreDeLaClase>.class); las clases persistentes
        	 
//        	 config.addAnnotatedClass(Cliente.class);
//        	 config.addAnnotatedClass(Particular.class);
//        	 config.addAnnotatedClass(Empresa.class);
//        	 config.addAnnotatedClass(CuentaCorriente.class);
        	 config.addAnnotatedClass(Vehiculo.class);
        	 config.addAnnotatedClass(VehiculoConCaja.class);
        	 config.addAnnotatedClass(Tractor.class);
        	 config.addAnnotatedClass(SolicitudEnvio.class);
        	 config.addAnnotatedClass(Paquete.class);
        	 config.addAnnotatedClass(Empleado.class);
        	 config.addAnnotatedClass(Sucursal.class);
        	 config.addAnnotatedClass(Direccion.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	//config.addAnnotatedClass(Particular.class);
        	 
        	 
             sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
